<?php 
class demo extends CI_Controller {
	function index() {
		
		$this->load->library('table');
		//$this->load->library('static_data');

		$data['demolist']=array(
			array('showDataFromMysql', ''),
			array('CRUD OPERATION', '21'),
			array('2', '22')
			);

		$this->load->view('template', $data);
	}
	
	function showDataFromMysql(){
		$this->load->model('demo_model');
		$data['rows'] = $this->demo_model->getAll2();
		$this->load->view('demo', $data);
	}
	
	/* 2 */
	function crud_index()
	{
		$data = array();
		$this->load->model('demo_model');
		if($query = $this->demo_model->get_records())
		{
			$data['records'] = $query;
		}
		
		$this->load->view('demo/crud', $data);
	}
	
	function create()
	{
		$data = array(
			'content' => $this->input->post('content')
		);
		
		$this->demo_model->add_record($data);
		$this->crud_index();
	}
	
	function update()
	{
		$data = array(
			'content' => 'Content should go here; it is updated.'	
		);
		
		$this->demo_model->update_record($data);
	}
	
	
	function delete()
	{
		$this->demo_model->delete_record();
		$this->crud_index();
	}
}
?>